var e = getApp();

Page({
    data: {
        shop_address: "",
        phone: "",
        shop_name: ""
    },
    onLoad: function(e) {
        this.getdata();
    },
    shop_name: function(e) {
        var n = e.detail.value;
        this.setData({
            shop_name: n
        });
    },
    phone: function(e) {
        var n = e.detail.value;
        this.setData({
            phone: n
        });
    },
    shop_address: function(e) {
        var n = e.detail.value;
        this.setData({
            shop_address: n
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getdata();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    submit: function() {
        var n = {
            shop_name: this.data.shop_name,
            phone: this.data.phone,
            shop_address: this.data.shop_address
        }, t = e.getNetAddresss("plugin.energy-cabin.frontend.dealer-terminal.store-dealer");
        e._getNetWork({
            url: t,
            data: n,
            success: function(e) {
                var n = e.data;
                1 == n.result ? (console.log(n), wx.showToast({
                    title: "提交成功",
                    icon: "none",
                    duration: 1e3,
                    success: function(e) {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                })) : wx.showToast({
                    title: n.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getdata: function() {
        wx.showLoading({
            title: "加载中"
        });
        var n = e.getNetAddresss("plugin.energy-cabin.frontend.dealer-terminal.get-shop-info"), t = this;
        e._getNetWork({
            url: n,
            success: function(e) {
                wx.hideLoading({
                    success: function(e) {}
                });
                var n = e.data;
                1 == n.result && (console.log(n), n.data && t.setData({
                    shop_name: n.data.shop_name,
                    phone: n.data.phone,
                    shop_address: n.data.shop_address
                }));
            },
            fail: function(e) {
                console.log(e), wx.hideLoading({
                    success: function(e) {}
                });
            }
        });
    }
});